package com.goambu.driver.view.components;


import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.goambu.driver.R;

public class BotonIconTexto extends LinearLayout {
	public ImageView imgIcon;
	public TextView txtAccion;
	public LinearLayout btn;

	private void inflate() {
		LayoutInflater layoutInflater = (LayoutInflater) getContext()
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		layoutInflater.inflate(R.layout.componente_boton_icon_texto, this);
		this.btn = (LinearLayout) findViewById(R.id.btn);
		this.imgIcon = (ImageView) findViewById(R.id.imgIcon);
		this.txtAccion = (TextView) findViewById(R.id.txtAccion);
	}

	public void setAtributos(int backgroundColorResource, int icon, String texto) {
		btn.setBackgroundResource(backgroundColorResource);
		imgIcon.setImageResource(icon);
		txtAccion.setText(texto);
	}
	
	public void setAtributos(int backgroundColorResource, String texto) {
		btn.setBackgroundResource(backgroundColorResource);
		imgIcon.setVisibility(GONE);
		txtAccion.setText(texto);
		
	}
	
	public void setTxtPadding(int top, int bottom){
		txtAccion.setPadding(0, top, 0, bottom);
	}

	public void setVisible(){
		this.setVisibility(View.VISIBLE);
	}
	public void setHidden(){
		this.setVisibility(View.GONE);
	}
	
	public BotonIconTexto(Context context) {
		super(context);
		inflate();
	}

	public BotonIconTexto(Context context, AttributeSet attrs) {
		super(context, attrs);
		inflate();
	}
	public String getText(){
		return this.txtAccion.getText().toString();
	}
	
	public void setText(String text)
	{
		txtAccion.setText(text);
	}

}
